﻿@model PhoneBilling.Models.Report8Model
@{
    ViewBag.Title = "长途统计";
    Layout = "~/Views/Shared/_Layout.cshtml"; 
}
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.async.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.edit.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.sortable.js")"></script>
<link href="@Url.Content("~/Content/js/jquery.treeview.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    function check(id) {
        var checked = $("#" + id).attr("checked");
        if (checked == "checked") {
            $("." + id).attr("checked", checked);
        }
        else {
            $("." + id).removeAttr("checked");
        }
    }
    function beforeSubmit() {
        var str = "";
        $(".group").each(function () {
            if ($(this).attr("checked") == "checked") {
                if (str == "")
                    str += $(this).attr("id");
                else
                    str += "!" + $(this).attr("id");
            }
        });
        $("#SelectItem").attr("value", str);
    }
    $(document).ready(function () {
        $("#tree").treeview();
    });
    function exportClick() {
        $(".export").val("True");
        beforeSubmit();
    }

    function searchClick() {
        $(".export").val("False");
        beforeSubmit();
    }
    $(document).ready(           
function () 
{  
    $(".myDatePickerClass1 ").datepicker({
        buttonImage: '@Url.Content("~/Content/image/calendar.gif")',               
        dateFormat: 'yy/mm/dd',                 
        showOn: 'button',               
        buttonImageOnly: true ,
        changeMonth:true,              
        changeYear:true,
    });   
    $(".myDatePickerClass2 ").datepicker({
        buttonImage: '@Url.Content("~/Content/image/calendar.gif")',               
        dateFormat: 'yy/mm/dd',                 
        showOn: 'button',               
        buttonImageOnly: true ,
        changeMonth:true,              
        changeYear:true,
    });
}       
);
</script>
@using (Html.BeginForm())
{
    <div>
        <div class="col33">
            <h3 class="tlt">
                请选择部门或者分组</h3>
            <ul id="tree" class="treeview-gray">
                @{foreach (var department in Model.DepartmentList)
                  {
                    <li class="closed">
                        <input type=checkbox id="@department.ID" onclick="check('@department.ID')"/><span
                            class="folder">@department.名称</span>
                        @if (department.分组List.Count > 0)
                        {
                            <ul>
                                @{foreach (var group1 in department.分组List)
                                  {
                                    <li class="closed">
                                        <input type=checkbox id="@group1.ID" class="@department.ID group" onclick="check('@group1.ID')"/><span
                                            class="folder">@group1.名称</span>
                                        @if (group1.分组List.Count > 0)
                                        {
                                            <ul>
                                                @{foreach (var group2 in group1.分组List)
                                                  {
                                                    <li class="closed">
                                                        <input type=checkbox id="@group2.ID" class="@department.ID @group1.ID group" onclick="check('@group2.ID')"/><span
                                                            class="folder">@group2.名称</span>
                                                        @if (group2.分组List.Count > 0)
                                                        {
                                                            <ul>
                                                                @{foreach (var group3 in group2.分组List)
                                                                  {
                                                                    <li>
                                                                        <input type=checkbox id="@group3.ID" class="@department.ID @group1.ID @group2.ID group" onclick="check('@group3.ID')"/><span
                                                                            class="folder">@group3.名称</span> </li>
                                                                  }}
                                                            </ul>
                                                        }
                                                    </li>
                                                  }}
                                            </ul>
                                        }
                                    </li>
                                  }}
                            </ul>
                        }
                    </li>
                  }}
            </ul>
        </div>
        <div class="col66">
            <h3 class="tlt">
                其他条件</h3>
            @Html.HiddenFor(m => m.SelectItem, new { id = "SelectItem" })
            @Html.HiddenFor(m => m.IsExport, new { @class = "export" })
            <div class="input-text">
                @Html.LabelFor(m => m.开始日期)
                @Html.TextBox("开始日期", Model.开始日期.ToString("d"), new { @class = "myDatePickerClass1" })
            </div>
            <div class="input-text">
                @Html.LabelFor(m => m.结束日期)
                @Html.TextBox("结束日期", Model.结束日期.ToString("d"), new { @class = "myDatePickerClass2" })
            </div>
            <div>
                <input type="submit" value="查询" class="input-submit" onclick="searchClick()" />
                <input type="submit" value="导出Excel" class="input-submit" onclick="exportClick()" />
            </div>
        </div>
    </div>
}
